/*--------------------------------------------------------------------------------*/
#ifndef __GRAPHIC_TEXTURE_MANAGER__
#define __GRAPHIC_TEXTURE_MANAGER__
/*--------------------------------------------------------------------------------*/
#include "primitives.h"
#include "object.h"
#include "util.h"
#include "map.h"
#include "graphic_texture.h"
#include "input_file_manager.h"
/*--------------------------------------------------------------------------------*/
#define GRAPHIC_TEXTURE_MANAGER_GetTexture				GRAPHIC_TEXTURE_MANAGER::GetInstance().GetTexture
#define GRAPHIC_TEXTURE_MANAGER_AddTexture				GRAPHIC_TEXTURE_MANAGER::GetInstance().AddTexture
#define GRAPHIC_TEXTURE_MANAGER_DoesTextureExist		GRAPHIC_TEXTURE_MANAGER::GetInstance().DoesTextureExist
#define GRAPHIC_TEXTURE_MANAGER_CreateTextureFromFile	GRAPHIC_TEXTURE_MANAGER::GetInstance().CreateTextureFromFile
/*--------------------------------------------------------------------------------*/
class GRAPHIC_TEXTURE_MANAGER : public OBJECT
{

	// -- PUBLIC

public:

    DECLARE_REF( GRAPHIC_TEXTURE_MANAGER );
    DECLARE_SINGLETON( GRAPHIC_TEXTURE_MANAGER );

    // .. CONSTRUCTORS

    GRAPHIC_TEXTURE_MANAGER() : OBJECT(), TextureTable()
    {

    }

    virtual ~GRAPHIC_TEXTURE_MANAGER()
    {
    }

    // .. METHODS

    BOOL DoesTextureExist( const TEXT & file_name ) const
    {
    	return TextureTable.HasKey( file_name );
    }

    GRAPHIC_TEXTURE::REF & GetTexture( const TEXT & texture_name )
    {
    	DEBUG_Require( TextureTable.HasKey( texture_name ) );

    	return TextureTable[ texture_name ];
    }

    VOID AddTexture( const TEXT & name, const GRAPHIC_TEXTURE::REF & texture )
    {
    	TextureTable.Add( name, texture );
    	DEBUG_LogLine( "Texture \"" + name + "\" added." );
    }

    VOID CreateTextureFromFile( const TEXT & file_name )
    {
    	DEBUG_Require( !TextureTable.HasKey( file_name ) );

    	TextureTable.Add( file_name, GRAPHIC_TEXTURE::CreateTextureFromFile( file_name ) );
    }

    // -- PRIVATE

private :

    // .. ATTRIBUTES

    MAP< TEXT, GRAPHIC_TEXTURE::REF >
		TextureTable;
};
/*--------------------------------------------------------------------------------*/
#endif
